package com.kaifamiao.address;

import java.net.InetAddress;
import java.net.InetSocketAddress;

public class InetSocketAddressTest {

    public static void main(String[] args) throws Exception {

        int port = 8848;
        InetSocketAddress first = new InetSocketAddress( port );
        System.out.println( first );

        InetAddress address = InetAddress.getLocalHost();
        InetSocketAddress second = new InetSocketAddress( address , port);
        System.out.println( second );


        String hostName = "D2D5";
        InetSocketAddress third = new InetSocketAddress( hostName, port );
        System.out.println( third );

        hostName = "10.0.4.97";
        third = new InetSocketAddress( hostName, port );
        System.out.println( third );


        byte[] ipBytes = { (byte)192, (byte)168, 0, (byte)128 };
        InetAddress addr = InetAddress.getByAddress(ipBytes);
        InetSocketAddress fourth = new InetSocketAddress( addr, port );
        System.out.println( fourth );
    }

}
